<template>
	<view>
		<!--查看群聊成员 -->
			
		<view class="content">
			<view class="item" v-for="(item,index) in dataList" :key="index">
				<image :src="item.avatar"
				class="nicknameImage"
				></image>
				
				<view class="nickname text-cut">{{item.nickname || ''}}</view>
			</view>
			
			<uni-load-more :status="status" :content-text="contentText" />
			
		</view>
		
		<!-- 更多 -->
		<uni-load-more :status="status" :content-text="contentText" />
		
	</view>
	
</template>

<script>
import { mapState, mapActions } from 'vuex';
export default {
	data() {
		return {
			user_ids:[],
			name:'',
			group_id:0,
			
			dataList:[
				// {
				// 	nickname:'昵称',
				// 	status:0,
				// 	id:10,
				// 	avatar:'/static/images/default/screen_icon_new.png',
				// }
			],
			current_page: 1, //当前页码
			last_page: 1, //总页码
			status: 'noMore',//noMore loading
			contentText: {
				contentdown: '',
				contentrefresh: '正在加载...',
				contentnomore: ''
			}
		}
	},
	
	onLoad(option) {
		if(option.group_id){
			this.group_id = option.group_id;
		}
		
		this.getList();
	},
	// 触底加载更多
	onReachBottom() {
		//判断是否最后一页
		if (this.current_page >= this.last_page) {
			this.status = 'noMore';
		} else {
			this.current_page = this.current_page + 1; //页码+1
			this.status = 'loading';
			this.getList();
		}
	},
	methods: {
		getList(){
			let that = this;
			this.status = 'loading';
			uni.request({
				url: '/chat/groupuserlist',
				data: {
					page: this.current_page,
					id: this.group_id,
				},
				success: res => {
					res = res.res;
					if (res.code === 1) {
						res.data.data.forEach(function(value,index){
							 value.selected = false;
						});
						
						that.dataList = [...that.dataList, ...res.data.data];
						that.current_page = res.data.current_page; //当前页码
						that.last_page = res.data.last_page; //总页码
						that.status = 'more';
					}
				}
			});
		},
		
	}
}	
</script>

<style lang="scss" scoped>
.search-form{
	background-color: #F7F7F7;
	margin-bottom: 24rpx;
	height: 70rpx;
	display: flex;
	align-items: center;
	padding-left: 32rpx;
}

.content{
	background: #ffffff;
	border-radius: 40rpx 40rpx 0rpx 0rpx;
	padding: 24rpx;
	height: 100vh;
	overflow-y: auto;
}

.color-search{
	color: #C7C7C7;
	margin-right: 20rpx;
}

.nicknameImage{
	width: 70rpx;
	height: 70rpx;
	border-radius: 50%;
	margin-left: 17rpx;
	margin-right: 17rpx;
}

.nickname{
	font-size: 28rpx;
	font-family: PingFang SC;
	font-weight: 400;
	color: #292929;
	width: 556rpx;
	border-bottom: 1rpx solid #EBEBEB;
	padding-bottom: 42rpx;
	padding-top: 42rpx;
}
.item{
	display: flex;
	align-items: center;
}

.btn{
	width: 702rpx;
	height: 88rpx;
	background: #9C3728;
	border-radius: 20rpx;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #ffffff;
}

.fixed-btn{
	display: flex;
	align-items: center;
	justify-content: center;
	position: fixed;
	bottom: 60rpx;
	left: 24rpx;
}
</style>